package fahrenbacher.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.TabLayoutPanel;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.DecoratedTabPanel;
import com.google.gwt.user.client.ui.CaptionPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.cellview.client.DataGrid;
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.cellview.client.Column;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import com.google.gwt.cell.client.DateCell;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.cellview.client.CellList;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.Cell.Context;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.widget.client.TextButton;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.PageSizePager;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.ToggleButton;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Carbon_Footprint implements EntryPoint {
// The list of data to display.
private ArrayList<Employee> EMPLOYEES = new ArrayList<Employee>();
public void onModuleLoad() {
EMPLOYEES.add(new Employee("a","b"));
EMPLOYEES.add(new Employee("a","b"));
EMPLOYEES.add(new Employee("a","b"));
// Add the nameField and sendButton to the RootPanel
// Use RootPanel.get() to get the entire body element
RootPanel rootPanel = RootPanel.get("nameFieldContainer");
//rootPanel.setSize("", "");
HorizontalPanel horizontalPanel = new HorizontalPanel();
horizontalPanel.setBorderWidth(1);
horizontalPanel.setSpacing(10);
rootPanel.add(horizontalPanel);
//horizontalPanel.setSize("448px", "105px");
//Image image = new Image((String) null);
// image.setAltText("Profile picture");
//horizontalPanel.add(image);
//image.setSize("150px", "150px");
Grid grid = new Grid(5, 2);
grid.setBorderWidth(1);
horizontalPanel.add(grid);
horizontalPanel.setCellVerticalAlignment(grid, HasVerticalAlignment.ALIGN_MIDDLE);
grid.setSize("236px", "123px");
Label lblName = new Label("Name ");
lblName.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
grid.setWidget(0, 0, lblName);
Label lblNewLabel = new Label("Some Name ");
lblNewLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
grid.setWidget(0, 1, lblNewLabel);
Label lblNewLabel_1 = new Label("ID");
lblNewLabel_1.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
grid.setWidget(1, 0, lblNewLabel_1);
Label lblNewLabel_2 = new Label("###### ");
lblNewLabel_2.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
grid.setWidget(1, 1, lblNewLabel_2);
Label lblNewLabel_3 = new Label("Grade2 ");
lblNewLabel_3.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
grid.setWidget(2, 0, lblNewLabel_3);
Label lblNewLabel_5 = new Label("##");
lblNewLabel_5.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
grid.setWidget(2, 1, lblNewLabel_5);
Label lblNewLabel_6 = new Label("Club ");
lblNewLabel_6.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
grid.setWidget(3, 0, lblNewLabel_6);
Label lblNewLabel_4 = new Label("Some Club");
lblNewLabel_4.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
grid.setWidget(3, 1, lblNewLabel_4);
Label lblNewLabel_7 = new Label("Total Carbon ");
lblNewLabel_7.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
grid.setWidget(4, 0, lblNewLabel_7);
Label lblNewLabel_8 = new Label("##");
lblNewLabel_8.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
grid.setWidget(4, 1, lblNewLabel_8);
HorizontalPanel horizontalPanel_1 = new HorizontalPanel();
horizontalPanel_1.setBorderWidth(1);
// rootPanel.add(horizontalPanel_1);
horizontalPanel_1.setSize("445px", "111px");
TabPanel tabPanel = new TabPanel();
//horizontalPanel_1.add(tabPanel);
tabPanel.setWidth("442px");
HTMLPanel panel = new HTMLPanel("New HTML");
tabPanel.add(panel, "New tab", false);
panel.setSize("5cm", "3cm");
HTMLPanel panel_1 = new HTMLPanel("New HTML");
tabPanel.add(panel_1, "New tab", false);
panel_1.setSize("5cm", "3cm");
SimplePanel simplePanel_1 = new SimplePanel();
rootPanel.add(simplePanel_1);
DockPanel dockPanel = new DockPanel();
rootPanel.add(dockPanel);
dockPanel.setSize("533px", "307px");
final DataGrid<Employee> dataGrid = new DataGrid<Employee>();
dockPanel.add(dataGrid, DockPanel.CENTER);
dataGrid.setWidth("250px");
dataGrid.setHeight("200px");
TextColumn<Employee> textColumn = new TextColumn<Employee>() {
@Override
public String getValue(Employee employee) {
return employee.getFirstname() ;
}
};
dataGrid.addColumn(textColumn, "First name");
textColumn.getFieldUpdater();
TextColumn<Employee> textColumn_1 = new TextColumn<Employee>() {
@Override
public String getValue(Employee object) {
return object.getLastName();
}
};
dataGrid.addColumn(textColumn_1, "Last Name");
textColumn_1.getFieldUpdater();
Button btnAddName = new Button("Add Name");
btnAddName.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
EMPLOYEES.add(new Employee("JKkabes","Ofbekfast"));
dataGrid.setRowCount(EMPLOYEES.size(), true);
dataGrid.setRowData(0, EMPLOYEES);
}
});
dockPanel.add(btnAddName, DockPanel.WEST);
dataGrid.setRowCount(EMPLOYEES.size(), true);
dataGrid.setRowData(0, EMPLOYEES);
}
}
class Employee {
private final String firstName;
private final String lastName;
public Employee(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstname(){
return firstName;
}
public String getLastName(){
return lastName;
}
}